package com.noreg.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * <p>Title: </p>
 * <p>desc:
 * <p>Copyright: Copyright(c)Gb 2011</p>
 * @author <a href="mailTo:jeson.sha@goodbabygroup.com">jeson.sha</a>
 * @time 2011-8-3 下午03:41:04
 * @version 1.0
 * @since
 */
public class BundleUtil {
	private static BundleUtil bd = null;
	static Properties p = new Properties();
	BundleUtil(){
		try {
			init();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static BundleUtil getInstance(){
		if(bd==null){
			bd = new BundleUtil();
		}
		return bd;
	}
	public void init() throws IOException{
		
		//String path = System.getProperty("user.dir")+"\\timer.properties";
		String path = new File(System.getProperty("user.dir")).getParentFile().getAbsolutePath()+"/timer.properties";
		FileInputStream ins =new FileInputStream(path);
		p.load(ins);
	}
	
	public String get(String key){
		return p.get(key)+"";
	}
	
	public void set(String k,String v){
		p.setProperty(k, v);
		
	}
	
	public static void main(String[] args) {
		BundleUtil bu = BundleUtil.getInstance();
		bu.set("page", "5025");
		System.out.println(bu.get("page"));
	}
}
